package cn.wb.addUser;

import cn.wb.base.util.MD5Utils;
import cn.wb.base.util.StrUtils;
import cn.wb.user.domain.User;
import cn.wb.user.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class AddTest {

    @Autowired
    private UserMapper userMapper;

    public void addUser(){
        List<User> list = new ArrayList<>();
        for (int i = 0;i<1000;i++){
            User user = new User();
            user.setUsername("zhangsan"+i);
            user.setPhone("1234567"+i);
            String str = StrUtils.getComplexRandomString(32);
            String pass = MD5Utils.encrypByMd5(str + "1");
            user.setPassword(pass);
            user.setSalt(str);
            user.setState(1);
            user.setCreatetime(new Date());
            user.setHeadImg("safasfsafsafsafasfsafsafsfaff");
            user.setEmail(1+"123@qq.com");
            list.add(user);
        }
        userMapper.batchAdd(list);
    }


}
